package com.ssy.lingxi.enhance.controller.process;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.enhance.constant.RoleTypeEnum;
import com.ssy.lingxi.enhance.model.dto.CommonIdDTO;
import com.ssy.lingxi.enhance.model.dto.CommonIdListDTO;
import com.ssy.lingxi.enhance.model.dto.ExamDTO;
import com.ssy.lingxi.enhance.model.qo.ProduceNoticeOrderQO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderDetailsVO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderListVO;
import com.ssy.lingxi.enhance.service.common.CommonService;
import com.ssy.lingxi.enhance.service.process.ProcessToBeSecondExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 加工能力 - 确认生产通知单(加工企业) - 待审核生产通知单(二级)
 * @author fhj
 * @version 2.0.0
 * @date 2020/10/20
 */
@Api(tags = "加工能力 - 确认生产通知单(加工企业) - 待审核生产通知单(二级)")
@RestController
@RequestMapping("/enhance/process/toBeSecondExam")
public class ProcessToBeSecondExamController extends BaseController {

    @Resource
    private ProcessToBeSecondExamService toBeSecondExamService;
    @Resource
    private CommonService commonService;

    @ApiOperation(value = "列表")
    @GetMapping(value = "/list")
    public Wrapper<PageData<ProduceNoticeOrderListVO>> list(@Valid ProduceNoticeOrderQO qo) {
        return toBeSecondExamService.list(qo, getSysUser());
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/details")
    public Wrapper<ProduceNoticeOrderDetailsVO> details(@Valid CommonIdDTO dto) {
        return commonService.details(dto.getId(), RoleTypeEnum.PROCESS.getCode(), getSysUser());
    }

    @ApiOperation(value = "审核")
    @PostMapping(value = "/exam")
    public Wrapper<Void> exam(@RequestBody @Valid ExamDTO dto) {
        return toBeSecondExamService.exam(dto, getSysUser());
    }

    @ApiOperation(value = "批量审核通过")
    @PostMapping(value = "/batchExamPass")
    public Wrapper<Void> batchExamPass(@RequestBody @Valid CommonIdListDTO dto) {
        return toBeSecondExamService.batchExamPass(dto, getSysUser());
    }
}
